package pers.cz.analysis.store;

import pers.cz.analysis.enums.ExportConf;
import pers.cz.analysis.store.excel.ExcelSotre;
import pers.cz.analysis.store.txt.TxtStore;
import pers.cz.jefconfig.config.JefConfiguration;
import utils.ReflectUtils;

/**
 * @program: Jef-code-analysis
 * @description: store工具
 * @author: Cheng Zhi
 * @create: 2023-10-11 21:37
 **/
public class StoreTools {

    /**
     * 反射获取store
     * @return
     */
    public static IStore getStore() {
        String storeName = JefConfiguration.get(ExportConf.JEF_ANALYSIS_SAVE_TYPE);
        switch (storeName) {
            case "excel":
                return ReflectUtils.newInstance(ExcelSotre.class);
            case "txt":
                return ReflectUtils.newInstance(TxtStore.class);
            case "db":
                throw new IllegalArgumentException("暂时不支持db");
            default:
                throw new IllegalArgumentException("暂时不支持" + storeName);
        }
    }
}
